package ThreadTest;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-23
 * Time: 10:57
 */
public class Deom3 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread a = new Thread(()->{
            synchronized(locker) {
                try {
                    locker.wait(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName());
            }
        },"a");
        Thread b = new Thread(()->{
            synchronized(locker) {
                try {
                    locker.wait(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName());
        },"b");
        Thread c = new Thread(()->{
            synchronized (locker) {
                try {
                    locker.wait(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName());
        },"c");
        a.start();
        b.start();
        c.start();
    }
}
